package com.sita.bike.ui.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.sita.bike.R;
import com.sita.bike.event.SpeedActionEvent;
import com.sita.tboard.ActivityBase;

import de.greenrobot.event.EventBus;

public class SpeedMeterPausedActivity extends ActivityBase {
    String TAG = SpeedMeterPausedActivity.class.getSimpleName();
    ImageView mImgViewStop;
    RelativeLayout mCancelLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_speed_meter_paused);
        mImgViewStop = (ImageView) findViewById(R.id.speed_meter_stop_icon);
        mImgViewStop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "onClick: stop");
                doStop();
            }
        });
        mCancelLayout = (RelativeLayout) findViewById(R.id.speed_paused_cancel_layout);
        mCancelLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "onClick: continue to track");
                doContinue();
            }
        });
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        doContinue();
    }

    private void doContinue() {
        EventBus.getDefault().post(new SpeedActionEvent(SpeedActionEvent.ACTION_CONTINUE));
        finish();
    }

    private void doStop() {
        EventBus.getDefault().post(new SpeedActionEvent(SpeedActionEvent.ACTION_OVER));
        finish();
    }
}
